/*
 * @Descripttion:
 * @version: 1.0.0
 * @Author: htang
 * @Date: 2023-11-05 00:39:23
 * @LastEditors: htang
 * @LastEditTime: 2024-03-06 15:01:14
 */
import 'uno.css';
import '/@/design/index.less';
// 注册图标
import 'virtual:svg-icons-register';
import App from './App.vue';
import { createApp } from 'vue';
import { initAppConfigStore } from '/@/logics/initAppConfig';
import { setupErrorHandle } from '/@/logics/error-handle';
import { router, setupRouter } from '/@/router';
import { setupRouterGuard } from '/@/router/guard';
import { setupStore } from '/@/store';
import { setupGlobDirectives } from '/@/directives';
import { setupI18n } from '/@/locales/setupI18n';
import { registerGlobComp } from '/@/components/registerGlobComp';
import { registerThirdComp } from '/@/settings/registerThirdComp';
// 注册online模块lib
import { registerPackages } from '/@/utils/monorepo/registerPackages';
import { setDomFontSize } from '/@/utils/dom.js';
import { isMobile } from '/@/utils'
import PhotoSwipeLightbox from 'photoswipe/lightbox';
import DataVVue3 from '@kjgl77/datav-vue3'
import 'photoswipe/style.css';

import '@/assets/js/marked.min.js'
import '@/assets/js/font_4042197_vr5c62twlzh.js'

import '@/assets/icons/iconfont.css'
// import '@/styles/index.less';

// 在本地开发中引入的,以提高浏览器响应速度
if (import.meta.env.DEV) {
  // @ts-ignore
  import('ant-design-vue/dist/antd.less');
}

if (!isMobile()) {
  setDomFontSize();
}

async function bootstrap() {
  // 创建应用实例
  const app = createApp(App);

  app.use(DataVVue3)

  // 多语言配置,异步情况:语言文件可以从服务器端获得
  await setupI18n(app);

  // 配置存储
  setupStore(app);

  // 初始化内部系统配置
  initAppConfigStore();

  // 注册外部模块路由(注册online模块lib)
  registerPackages(app);

  // 注册全局组件
  registerGlobComp(app);

  //CAS单点登录
  // await useSso().ssoLogin();

  // 配置路由
  setupRouter(app);

  // 路由保护
  setupRouterGuard(router);

  // 注册全局指令
  setupGlobDirectives(app);

  // 配置全局错误处理
  setupErrorHandle(app);

  // 注册第三方组件
  await registerThirdComp(app);

  // 当路由准备好时再执行挂载( https://next.router.vuejs.org/api/#isready)
  await router.isReady();

  // 挂载应用
  app.mount('#app', true);
}

bootstrap();